﻿
@{
    ViewBag.Title = "InveAddView";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}


<div id="addLayer" style="display:block;">
    <form class="layui-form" id="InveAddFrom" style="margin-top:10px;">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>物料信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">物料编码</label>
                <div class="layui-input-inline" style="width:100px;">
                    <input type="text" name="Code" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">规格名称</label>
                <div class="layui-input-inline" style="width:300px;">
                    <input type="text" name="Specification" value="" placeholder="必填" required lay-verify="required" class="layui-input">
                </div>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>采购信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width:50px;">单位</label>
                <div class="layui-inline" style="width:50px;">
                    <input type="text" name="Unit" value="" placeholder="必填" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:85px;">ERP提报数量</label>
                <div class="layui-input-inline" style="width:80px;">
                    <input type="number" name="RequAmount" value="" placeholder="必填" required lay-verify="required|number" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:100px;">实际收货数量</label>
                <div class="layui-input-inline" style="width:80px;">
                    <input type="number" name="ReceAmount" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:60px;">收货日期</label>
                <div class="layui-input-inline" style="width:100px;">
                    <input type="text" name="ReceDate" value="" id="ReceDate" placeholder="请输选择时间" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>分包单位使用情况</legend>
        </fieldset>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width:100px;">分包单位领用量</label>
                <div class="layui-input-inline" style="width:80px;">
                    <input type="number" name="SubTakeAmount" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:60px;">领用时间</label>
                <div class="layui-input-inline" style="width:100px;">
                    <input type="text" name="SubRecedate" value="" id="SubRecedate" placeholder="请输选择时间" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:50px;">领用人</label>
                <div class="layui-inline" style="width:80px;">
                    <input type="text" name="SubContact" value="" class="layui-input">
                </div>
            </div>
            @*<div class="layui-inline">
            <label class="layui-form-label" style="width:100px;">分包单位退料</label>
            <div class="layui-input-inline" style="width:80px;">
                <input type="number" name="SubRefuAmount" value="" class="layui-input">
            </div>
        </div>*@
            @*<div class="layui-inline">
                <label class="layui-form-label" style="width:60px;">退料时间</label>
                <div class="layui-input-inline" style="width:100px;">
                    <input type="text" name="SubRefuDate" value="" id="SubRefuDate" placeholder="请输选择时间" autocomplete="off" class="layui-input">
                </div>
            </div>*@
        </div>

        <fieldset class="layui-elem-field layui-field-title">
            <legend>结算信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width:100px;">现场实际用料</label>
                <div class="layui-input-inline" style="width:80px;">
                    <input type="number" name="SubUseAmount" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width:100px;">结算书用料</label>
                <div class="layui-input-inline" style="width:80px;">
                    <input type="number" name="SettAmount" value="" class="layui-input">
                </div>
            </div>
            @*<div class="layui-inline">
                <label class="layui-form-label" style="width:100px;">退回公司数量</label>
                <div class="layui-input-inline" style="width:80px;">
                    <input type="number" name="RemaAmount" value="" class="layui-input">
                </div>
            </div>*@
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline" style="width:400px;">
                <input type="text" name="MaterialMemo" value="" class="layui-input">
            </div>
            <button type="button" class="layui-btn" id="BtnSave">保存</button>
        </div>
        <button type="submit" id="mysubmit" class="layui-btn" lay-submit lay-filter="formVerify" style="display:none;">立即提交</button>
    </form>
</div>
<script type="text/javascript">
    var ProjectId = "@ViewBag.ProjectId"
    
    layui.use(['form', 'table', 'upload', 'layer','laydate'], function () {
        var form = layui.form;
        var table = layui.table;
        var layer = layui.layer;
        var laydate = layui.laydate;

        var IsValidate = 0;

        laydate.render({
            elem: '#ReceDate' //指定元素
        });
        laydate.render({
            elem: '#SubRecedate' //指定元素
        });
        laydate.render({
            elem: '#SubRefuDate' //指定元素
        });

        form.on('submit(formVerify)', function (data) {
            //layer.msg(JSON.stringify(data.field));
            IsValidate = 1;
            return false;
        });

        $("#BtnSave").on("click", function () {

            $("#mysubmit").click();
            if (IsValidate == 1) {
                IsValidate = 0;
                var obj = $("#InveAddFrom").serializeArray();
                var data = {};
                $.each(obj, function (i, v) {
                    data[v.name] = v.value;
                });
                data["ProjectId"] = ProjectId;
                //表示新增
                $.ajax({
                    type: "POST",
                    url: "/Inventory/InveAdd",
                    async: false,
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(data),
                    success: function (msg) {
                        if (msg.result == "OK") {
                            parent.layer.msg('新增成功', { icon: 6, time: 1000 });
                            parent.table.reload("demo");
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);

                            //parent.layui.admin.events.closeThisTabs();
                        } else {
                            alert(msg.result);
                        }
                    }
                });
                //alert(JSON.stringify(data));
            }
        });
    });

</script>


